Networks and the Internet网络与互联网
Every time you load a webpage, stream a video, or send a message, data travels across a web of interconnected devices governed by precise rules called protocols. This guide explains how networks are built (LAN, WAN, topologies), how the Internet breaks data into packets and routes them across the globe, how IP addresses and DNS let you reach any machine by name, what TCP/IP and HTTP/HTTPS actually do, how the OSI seven-layer model organises those rules, and how firewalls and encryption keep traffic safe. It closes by untangling the Web from the Internet itself.每当你加载网页、播放视频或发送消息,数据都在由精确规则(协议,protocol)控制的互联设备网络中传输。本指南讲解网络(network,网络)的构建方式(局域网 LAN、广域网 WAN、拓扑结构),互联网(Internet,互联网)如何将数据拆成数据包(packet,数据包)并路由到全球各地,IP地址(IP address,IP地址)和域名系统(DNS,域名系统)如何让你用名字访问任何机器,TCP/IP 和 HTTP/HTTPS 实际上做什么,OSI 七层模型如何组织这些规则,以及防火墙(firewall,防火墙)和加密如何保护流量安全。最后辨析万维网(Web)与互联网本身的区别。
What is a Network?什么是网络?
- Define a network, a LAN and a WAN, and tell LAN from WAN by geographic scope and ownership.
- Draw and label a star topology, and name the bus, ring and mesh topologies with one strength or weakness of each.
- Calculate how many links a star and a full mesh need for n devices.
- Explain what a single point of failure is and say which topology has one.
- Choose a topology for a given scenario and justify the choice.
- 定义网络、局域网(LAN)和广域网(WAN),并按地理范围和所有权区分局域网与广域网。
- 画出并标注星型拓扑,说出总线型、环型和网状型拓扑,并各举一个优点或缺点。
- 计算 n 台设备的星型拓扑和全网状拓扑各需要多少条链路。
- 解释什么是单点故障(single point of failure),并指出哪种拓扑存在单点故障。
- 为给定场景选择拓扑并说明理由。
- Network网络: two or more devices connected so they can share data and resources. BC Computer Studies 10 Content: "wired and wireless computer networking (network cards, routers, switches, cables, modems, network types).":两台或更多设备相互连接以共享数据和资源。BC Computer Studies 10 内容:"有线和无线计算机网络(网卡、路由器、交换机、电缆、调制解调器、网络类型)。"
- LAN (Local Area Network)局域网(LAN): a network confined to a small geographic area, e.g. one building or campus. Devices connect via Ethernet cable or Wi-Fi. High speed, privately owned.:局限于较小地理区域(如一栋建筑或校园)的网络。设备通过以太网线缆或 Wi-Fi 连接。速度快,私有。
- WAN (Wide Area Network)广域网(WAN): a network spanning a large geographic area, linking LANs together. The Internet is the world's largest WAN. BC CIS 11 Content (verbatim): "model-wide area networks (WANs) and local area networks (LANs).":跨越大地理区域、将多个局域网连接在一起的网络。互联网是世界上最大的广域网。BC CIS 11 内容(原文):"广域网(WAN)和局域网(LAN)模型。"
- Network topology拓扑结构: the arrangement of how devices are connected. Common topologies: bus (all on one cable), star (all connect to a central switch, most common today), ring (each device connects to the next), mesh (every device connects to every other, fault tolerant, used in WANs). CSTA 3A-NI-04: "relationship between routers, switches, servers, topology, and addressing.":设备连接方式的排布。常见拓扑:总线型(所有设备连一条电缆)、星型(所有设备连接到中央交换机,当今最常见)、环型(每台设备连接到下一台)、网状型(每台设备与其他所有设备连接,容错性强,用于广域网)。CSTA 3A-NI-04:"路由器、交换机、服务器、拓扑结构和寻址之间的关系。"
Worked Example 1: Reading a star topology例题 1:读懂星型拓扑
Star topology (most common in modern LANs): all devices connect to one central switch or router.星型拓扑(现代局域网最常见):所有设备连接到一个中央交换机或路由器。
PC1 ----+
|
PC2 ----+---- Switch/Router ---- Internet
|
PC3 ----+
|
Printer--+
In a star topology, if the central switch fails, all devices lose connectivity; the switch is a single point of failure. In a mesh topology, data can reroute around failed nodes, making it fault-tolerant. CSTA 3A-NI-04 asks you to "evaluate the scalability and reliability of networks"; topology is a key factor.在星型拓扑中,若中央交换机故障,所有设备失去连接,交换机是单点故障。在网状拓扑中,数据可以绕过故障节点重新路由,因此具有容错性。CSTA 3A-NI-04 要求你"评估网络的可扩展性和可靠性",拓扑结构是关键因素。
Worked Example 2: Link counts for a star and a full mesh例题 2:星型与全网状的链路数
A computer lab has 6 devices. (a) How many cables does a star topology need? (b) How many links does a full mesh need? (c) Repeat both for a campus with 20 devices. (d) What does the mesh buy you, and what does it cost?一间机房有 6 台设备。(a)星型拓扑需要多少条线缆?(b)全网状拓扑需要多少条链路?(c)对有 20 台设备的校园重复(a)和(b)。(d)网状拓扑带来什么好处,又付出什么代价?
(a) Star. Every device has one cable to the central switch, so the number of cables equals the number of devices: 6 devices need 6 cables.(a) 星型。每台设备各用一条线缆连到中央交换机,所以线缆数等于设备数:6 台设备需要 6 条线缆。
(b) Full mesh. Every pair of devices gets its own link. There are n choices for one end and n − 1 for the other, and each pair is counted twice, so links = n × (n − 1) ÷ 2. For 6 devices: 6 × 5 ÷ 2 = 15 links.(b) 全网状。每一对设备都有一条独立链路。一端有 n 种选择,另一端有 n − 1 种,而每一对被数了两次,所以链路数 = n × (n − 1) ÷ 2。6 台设备:6 × 5 ÷ 2 = 15 条链路。
(c) 20 devices. Star: 20 cables. Mesh: 20 × 19 ÷ 2 = 190 links. Check with code:(c) 20 台设备。星型:20 条线缆。网状:20 × 19 ÷ 2 = 190 条链路。用代码验证:
for n in (6, 20):
star = n
mesh = n * (n - 1) // 2
print(n, star, mesh)
# output:
# 6 6 15
# 20 20 190
(d) Tradeoff. In a mesh, if one link fails the data can take another path, so no single failure cuts anyone off. The cost grows with the square of the number of devices: going from 6 to 20 devices (about 3.3 times as many) raises the links from 15 to 190 (about 12.7 times as many). A star stays cheap, but the switch is a single point of failure: if it fails, all devices lose connectivity, while a broken cable disconnects only one device. Real networks often use a partial mesh as a compromise.(d) 权衡。在网状拓扑中,某条链路故障时数据可以走另一条路径,所以任何单点故障都不会让某台设备断网。成本随设备数的平方增长:设备从 6 台增至 20 台(约 3.3 倍),链路从 15 条增至 190 条(约 12.7 倍)。星型一直很便宜,但交换机是单点故障:交换机坏了,所有设备都断网,而一条线缆断了只会让一台设备断网。现实中的网络常用部分网状作为折中。
Why this works: a topology is a counting problem plus a failure question. Count the links to see the cost, then ask what happens when one part fails.为什么这样做:拓扑既是计数问题,也是故障问题。先数链路得到成本,再问某一部分故障时会怎样。
When a question says distinguish LAN from WAN, give both sides: a LAN covers one building or campus and is privately owned; a WAN covers a large area and links LANs together. The number of devices does not decide it: a hospital with 200 devices in one building is still a LAN. When it says draw, label the central switch and every device. Common error: saying the cable is the weak point of a star topology; the switch is.
题目说区分(distinguish)局域网和广域网时,两边都要写:局域网覆盖一栋建筑或一个校园,属于私有;广域网覆盖大范围并把多个局域网连起来。设备数量不能决定类型:一栋楼里有 200 台设备的医院仍然是局域网。题目说画图(draw)时,要标出中央交换机和每台设备。常见错误:说星型拓扑的薄弱点是线缆,其实是交换机。
Define LAN and WAN, and say which one the Internet is.定义局域网和广域网,并说明互联网属于哪一种。
A LAN (local area network) covers a small area such as one building or campus and is usually privately owned. A WAN (wide area network) spans a large area and links LANs together. The Internet is the largest WAN.
局域网(LAN)覆盖一栋建筑或一个校园这样的小范围,通常是私有的。广域网(WAN)跨越大范围,把多个局域网连在一起。互联网是最大的广域网。
A hospital has 200 devices in one building, all connected through switches. Is this a LAN or a WAN? Why?一家医院在同一栋楼里有 200 台设备,全部通过交换机相连。这是局域网还是广域网?为什么?
It is a LAN. What matters is geographic scope and ownership (one building, privately owned), not the number of devices. If the hospital also linked three buildings across the city with leased lines, those long links would form a WAN.
这是局域网。关键是地理范围和所有权(一栋楼、私有),而不是设备数量。如果医院再用专线连接全城的三栋楼,这些远距离链路就构成广域网。
How many links does a ring of 8 devices need, and how many does a full mesh of 8 devices need? Which one is more expensive?8 台设备的环型拓扑需要多少条链路?8 台设备的全网状拓扑呢?哪个更贵?
Ring: each device connects to the next and the last connects back to the first, so 8 links. Full mesh: 8 × 7 ÷ 2 = 28 links. The mesh is more expensive (3.5 times the links) but has many alternative paths.
环型:每台设备连到下一台,最后一台再连回第一台,共 8 条链路。全网状:8 × 7 ÷ 2 = 28 条链路。网状更贵(链路是环型的 3.5 倍),但有很多备用路径。
A small clinic wants to add devices easily, and a broken cable should disconnect only one device. Which topology fits, and what is its weakness?一家小诊所希望方便地增加设备,并且一条线缆断了只应让一台设备断网。哪种拓扑合适?它的弱点是什么?
A star topology. Each device has its own cable to the switch, so adding a device means one new cable and a broken cable affects one device. The weakness is the central switch, a single point of failure.
星型拓扑。每台设备都有一条自己的线缆连到交换机,所以增加设备只需一条新线缆,一条线缆断了只影响一台设备。弱点是中央交换机,它是单点故障。
The Internet and How Data Travels互联网与数据的传输方式
- Define a packet and name the header fields it carries (source IP, destination IP, sequence number).
- Explain three benefits of packet switching and how a receiver reorders packets.
- Calculate how many packets a file needs from its size and the payload per packet.
- Calculate transfer time = size ÷ bandwidth, converting bytes to bits and Mbps to MB/s.
- Distinguish bandwidth from latency and say which one a given problem is about.
- 定义数据包(packet),并说出它头部携带的字段(源 IP、目标 IP、序列号)。
- 解释分组交换的三个优势,以及接收方如何给数据包重新排序。
- 根据文件大小和每个数据包的载荷量,计算需要多少个数据包。
- 计算传输时间 = 大小 ÷ 带宽,并完成字节到比特、Mbps 到 MB/s 的换算。
- 区分带宽(bandwidth)与延迟(latency),并判断一个问题讲的是哪一个。
- Packet数据包: a small chunk of data, typically 1,500 bytes or less, with a header containing the sender's IP address, the destination IP address, the packet number, and total packet count. AP CSP Big Idea 4 (CSN) describes the Internet as a network of networks that sends data as packets.:一小块数据,通常不超过 1,500 字节,头部包含发送方 IP 地址、目标 IP 地址、数据包编号和总包数。AP CSP 大概念 4(CSN)把互联网描述为网络的网络,数据以数据包形式传输。
- Packet switching分组交换: each packet can take a different route to the destination. Routers forward each packet along whichever path is fastest at that moment. Packets are reassembled in order at the destination.:每个数据包可以走不同路径到达目的地。路由器将每个数据包沿当时最快的路径转发。数据包在目的地按序重新组装。
- Fault tolerance容错性: because packets can reroute around failed nodes, the Internet continues to work even when some routers go down. AP CSP topic 4.2 (Fault Tolerance) covers this. CSTA 3A-NI-04: "evaluate the scalability and reliability of networks.":因为数据包可以绕过故障节点重新路由,即使某些路由器宕机,互联网仍能继续工作。AP CSP 主题 4.2(容错)涵盖此内容。CSTA 3A-NI-04:"评估网络的可扩展性和可靠性。"
Worked Example 3: Following a 3-packet message例题 3:跟踪一条 3 包消息
Sending a 3-packet message from your laptop to a web server.从你的笔记本电脑向 Web 服务器发送一条 3 包消息。
Your Laptop
|
| Packets 1, 2, 3 (may take different routes)
v
Router A ---Pkt1---> Router C ---Pkt1---> Web Server
| ^
+---Pkt2---> Router B ---Pkt2---+
| |
+---Pkt3---> Router D ---Pkt3---+
(third route)
Web Server: receives Pkt3, Pkt1, Pkt2 (out of order)
reassembles in order using packet numbers
sends ACK (acknowledgement) for each packet
Each router reads the destination IP address on the packet header and forwards the packet toward the destination via the best available route. The web server uses the packet-number field to reorder packets even if they arrive out of sequence. This is packet switching in action.每台路由器读取数据包头部的目标 IP 地址,并通过当前最佳可用路由将数据包转发至目的地。Web 服务器利用数据包编号字段对数据包重新排序,即使它们不按顺序到达也没关系。这就是分组交换的实际运作。
Worked Example 4: Packet counts and transfer time例题 4:数据包数量与传输时间
A 3 MB file (take 1 MB = 1,000,000 bytes) is sent over a link with bandwidth 8 Mbps and one-way latency 40 ms. Each packet is at most 1,500 bytes: 1,460 bytes of data (the payload) plus 40 bytes of headers. (a) How many packets are needed? (b) What is the ideal transfer time, ignoring headers? (c) What is it once headers are counted? (d) When does the last bit arrive? (e) If 12 packets are lost, how many bytes must be resent?一个 3 MB 的文件(取 1 MB = 1,000,000 字节)通过带宽 8 Mbps、单向延迟 40 ms 的链路发送。每个数据包最多 1,500 字节:1,460 字节数据(载荷)加 40 字节头部。(a)需要多少个数据包?(b)忽略头部时,理想传输时间是多少?(c)计入头部后是多少?(d)最后一个比特何时到达?(e)如果丢了 12 个数据包,需要重传多少字节?
(a) Packets. 3,000,000 ÷ 1,460 = 2,054.79, and a fraction of a packet still needs a whole packet, so round up: 2,055 packets. Check: 2,054 full packets carry 2,054 × 1,460 = 2,998,840 bytes, and the last one carries the remaining 3,000,000 − 2,998,840 = 1,160 bytes.(a) 数据包数。3,000,000 ÷ 1,460 = 2,054.79,不足一个包的部分也要占一个完整的包,所以向上取整:2,055 个数据包。验证:2,054 个满包携带 2,054 × 1,460 = 2,998,840 字节,最后一个包携带剩余的 3,000,000 − 2,998,840 = 1,160 字节。
(b) Ideal time. Bandwidth is in bits per second, the file is in bytes, so convert first: 3,000,000 bytes × 8 = 24,000,000 bits. Time = 24,000,000 ÷ 8,000,000 = 3.0 s. (Mbps means megabits per second; 8 Mbps = 1 MB/s, so 3 MB takes 3 s.)(b) 理想时间。带宽的单位是比特每秒,文件的单位是字节,所以先换算:3,000,000 字节 × 8 = 24,000,000 比特。时间 = 24,000,000 ÷ 8,000,000 = 3.0 秒。(Mbps 是兆比特每秒;8 Mbps = 1 MB/s,所以 3 MB 需要 3 秒。)
(c) With headers. 2,054 packets of 1,500 bytes plus a last packet of 1,160 + 40 = 1,200 bytes: 2,054 × 1,500 + 1,200 = 3,082,200 bytes on the wire. Time = 3,082,200 × 8 ÷ 8,000,000 = 3.0822 s, about 3.08 s.(c) 计入头部。2,054 个 1,500 字节的包,加上最后一个 1,160 + 40 = 1,200 字节的包:2,054 × 1,500 + 1,200 = 3,082,200 字节在线路上传输。时间 = 3,082,200 × 8 ÷ 8,000,000 = 3.0822 秒,约 3.08 秒。
(d) Latency. Latency is a delay that does not depend on file size. The last bit leaves after 3.0822 s and needs 40 ms to travel: 3.0822 + 0.040 = 3.1222 s, about 3.12 s (ignoring acknowledgements and the slow start of a real connection).(d) 延迟。延迟是与文件大小无关的时间。最后一个比特在 3.0822 秒后发出,再用 40 毫秒传到对方:3.0822 + 0.040 = 3.1222 秒,约 3.12 秒(忽略确认包和真实连接的慢启动)。
(e) Loss. Only the lost packets are resent: 12 × 1,500 = 18,000 bytes, which is 12 of 2,055 packets (0.58%), not the whole 3 MB. The code below repeats parts (a) to (d):(e) 丢包。只需重传丢失的数据包:12 × 1,500 = 18,000 字节,即 2,055 个包中的 12 个(0.58%),而不是整个 3 MB。下面的代码重复 (a) 到 (d) 的计算:
import math
file_bytes = 3_000_000 # 3 MB, taking 1 MB = 10**6 bytes
payload = 1460 # data bytes per packet (1500-byte packet minus 40 header bytes)
header = 40 # 20 bytes IP + 20 bytes TCP
packets = math.ceil(file_bytes / payload)
last_payload = file_bytes - (packets - 1) * payload
wire_bytes = (packets - 1) * (payload + header) + (last_payload + header)
link_bps = 8_000_000 # 8 Mbps = 8 million bits per second
ideal_s = file_bytes * 8 / link_bps
real_s = wire_bytes * 8 / link_bps
print("packets:", packets)
print("last payload:", last_payload)
print("bytes on the wire:", wire_bytes)
print("ideal time (s):", ideal_s)
print("with headers (s):", real_s)
print("plus 40 ms latency (s):", round(real_s + 0.040, 4))
# output:
# packets: 2055
# last payload: 1160
# bytes on the wire: 3082200
# ideal time (s): 3.0
# with headers (s): 3.0822
# plus 40 ms latency (s): 3.1222
Bandwidth versus latency. Doubling the bandwidth to 16 Mbps halves the 3.0 s of sending time to 1.5 s, but the 40 ms latency is unchanged. For one 1,500-byte packet the sending time is only 1,500 × 8 ÷ 8,000,000 = 1.5 ms, so latency (40 ms) dominates: a bigger pipe does not make a short message arrive sooner. If 1 MB meant 220 = 1,048,576 bytes instead, the file would be 3,145,728 bytes and the ideal time 3.1457 s; always say which meaning you use.带宽与延迟。把带宽翻倍到 16 Mbps,3.0 秒的发送时间减半为 1.5 秒,但 40 毫秒的延迟不变。对一个 1,500 字节的包,发送时间只有 1,500 × 8 ÷ 8,000,000 = 1.5 毫秒,所以延迟(40 毫秒)占主导:更宽的管道不会让短消息更快到达。如果 1 MB 取 220 = 1,048,576 字节,文件就是 3,145,728 字节,理想时间为 3.1457 秒;务必说明你用的是哪一种含义。
Why this works: convert to the same unit (bits), divide size by bandwidth, then add latency separately because it is a delay, not a rate.为什么这样做:先统一单位(比特),用大小除以带宽,再单独加上延迟,因为延迟是一段时间,而不是速率。
For a calculate question, write the unit conversion as its own line (bytes × 8 = bits; Mbps means megabits per second) and say whether 1 MB is 106 or 220 bytes. For explain why the Internet uses packets, give all three benefits: parallel routes, only lost packets are resent, bandwidth is shared. Common errors: mixing bytes and bits in one formula, reading Mbps as MB/s (they differ by a factor of 8), and treating latency as if more bandwidth would fix it.
遇到计算(calculate)题,把单位换算单独写成一行(字节 × 8 = 比特;Mbps 指兆比特每秒),并说明 1 MB 取 106 还是 220 字节。遇到解释互联网为什么使用数据包时,三个优势都要写:并行路径、只重传丢失的包、带宽共享。常见错误:在同一个公式里混用字节和比特,把 Mbps 当成 MB/s(两者相差 8 倍),以及以为增加带宽就能解决延迟。
A 12 MB file (1 MB = 1,000,000 bytes) is downloaded over a 96 Mbps connection. What is the ideal download time?一个 12 MB 的文件(1 MB = 1,000,000 字节)通过 96 Mbps 的连接下载。理想下载时间是多少?
12 MB = 12,000,000 bytes × 8 = 96,000,000 bits. Time = 96,000,000 ÷ 96,000,000 = 1.0 s. (96 Mbps is 12 MB/s, so 12 MB takes 1 s.)
12 MB = 12,000,000 字节 × 8 = 96,000,000 比特。时间 = 96,000,000 ÷ 96,000,000 = 1.0 秒。(96 Mbps 等于 12 MB/s,所以 12 MB 需要 1 秒。)
A message of 10,000 bytes is split into packets with at most 1,460 bytes of data each. How many packets are needed, and how big is the last one?一条 10,000 字节的消息被拆成数据包,每个包最多携带 1,460 字节数据。需要多少个数据包?最后一个有多大?
10,000 ÷ 1,460 = 6.85, rounded up to 7 packets. Six full packets carry 6 × 1,460 = 8,760 bytes, so the last packet carries 10,000 − 8,760 = 1,240 bytes of data.
10,000 ÷ 1,460 = 6.85,向上取整为 7 个数据包。6 个满包携带 6 × 1,460 = 8,760 字节,所以最后一个包携带 10,000 − 8,760 = 1,240 字节数据。
One 1,500-byte packet crosses a link with latency 40 ms. Compare the total delay at 8 Mbps and at 80 Mbps. Does ten times the bandwidth give ten times faster delivery?一个 1,500 字节的数据包通过延迟为 40 ms 的链路。比较 8 Mbps 和 80 Mbps 时的总延迟。带宽增加十倍,送达速度会快十倍吗?
Sending time = 1,500 × 8 ÷ bandwidth: 1.5 ms at 8 Mbps and 0.15 ms at 80 Mbps. Total delay = 40 + 1.5 = 41.5 ms versus 40 + 0.15 = 40.15 ms. No: latency dominates for a small message, so the delivery time barely changes.
发送时间 = 1,500 × 8 ÷ 带宽:8 Mbps 时为 1.5 ms,80 Mbps 时为 0.15 ms。总延迟 = 40 + 1.5 = 41.5 ms 对 40 + 0.15 = 40.15 ms。不会:对小消息来说延迟占主导,所以送达时间几乎不变。
Packets 3, 1, 2 of a file arrive in that order, and packet 2 is damaged and dropped. What does the receiver do?一个文件的数据包按 3、1、2 的顺序到达,其中包 2 损坏并被丢弃。接收方怎么做?
It uses the sequence numbers to put the packets in order, notices that packet 2 is missing or unacknowledged, and the sender retransmits only packet 2. The other packets are not resent.
接收方用序列号给数据包排序,发现包 2 缺失或未被确认,发送方只重传包 2。其他数据包不用重发。
IP Addresses and DNSIP地址与域名系统
- State what an IP address is and what DNS does, and why both are needed.
- Write an IPv4 address as four numbers from 0 to 255 (32 bits), spot an invalid one, and compute 232 and 2128.
- Calculate the usable hosts in a subnet as 2h − 2 and choose the smallest prefix for a number of devices.
- Trace a DNS lookup through the resolver, root, TLD and authoritative servers, and explain caching.
- Distinguish public from private addresses and say what NAT does.
- 说明什么是 IP 地址、DNS 的作用,以及为什么两者都需要。
- 把 IPv4 地址写成四个 0 到 255 的数字(32 位),识别无效地址,并计算 232 和 2128。
- 用 2h − 2 计算子网中可用的主机数,并为给定设备数选出最小的前缀。
- 追踪经过解析器、根服务器、顶级域服务器和权威服务器的 DNS 查找,并解释缓存。
- 区分公有地址与私有地址,并说明 NAT 的作用。
- IP addressIP地址: a unique numerical label assigned to every device on a network. IPv4: 32-bit, written as four 0–255 numbers separated by dots, e.g.
192.168.1.1. IPv6: 128-bit, written in hex with colons, e.g.2001:0db8::1. CSTA 3A-NI-04 expects you to describe "addressing" as part of network scalability.:分配给网络上每台设备的唯一数字标签。IPv4:32 位,以点分隔四个 0–255 的数字,如192.168.1.1。IPv6:128 位,以十六进制加冒号书写,如2001:0db8::1。CSTA 3A-NI-04 要求你将"寻址"描述为网络可扩展性的一部分。 - DNS (Domain Name System)域名系统(DNS): the Internet's "phone book." Translates human-readable domain names (e.g.
google.com) into IP addresses (e.g.142.250.80.46) that routers can forward packets to. Without DNS you would have to memorise IP addresses for every website.:互联网的"电话簿"。将人类可读的域名(如google.com)翻译成路由器可以转发数据包的 IP 地址(如142.250.80.46)。没有 DNS,你必须记住每个网站的 IP 地址。 - Public vs private IP公有 IP 与私有 IP: private IP addresses (e.g.
192.168.x.x) are used inside a LAN and are not routable on the public Internet. Your router's public IP is the address the rest of the world sees. NAT (Network Address Translation) maps many private addresses to one public IP.:私有 IP 地址(如192.168.x.x)在局域网内使用,不可在公共互联网上路由。你的路由器的公有 IP 是外部世界看到的地址。NAT(网络地址转换)将多个私有地址映射到一个公有 IP。
Worked Example 5: DNS lookup step by step例题 5:DNS 查找的逐步过程
What happens when you type www.example.com in your browser?当你在浏览器中输入 www.example.com 时会发生什么?
Browser DNS Resolver Root DNS .com DNS example.com DNS | | | | | |--"www.example.com?"--->| | | | | |---"who is .com?"---->| | | | |<---"ask .com DNS"-----| | | | |---"who is example.com?"---------->| | | |<---"ask example.com DNS"-----------| | | |---"IP of www.example.com?"---------------------->| | |<---"93.184.216.34"----------------------------- | |<---"93.184.216.34"-----| | |---TCP connection to 93.184.216.34:80/443 (HTTP/HTTPS)-----> Web Server
The DNS resolver caches the result so future lookups are instant. Your router or ISP typically acts as the DNS resolver. This hierarchical system allows the Internet's ~350 million domain names to be looked up without any single server knowing them all.DNS 解析器会缓存结果,使后续查找即时完成。你的路由器或 ISP 通常充当 DNS 解析器。这种层级系统使互联网约 3.5 亿个域名无需任何单一服务器全部知晓即可被查找。
Worked Example 6: Counting addresses and sizing a subnet例题 6:统计地址数量并确定子网大小
(a) How many addresses does IPv4 have, and how many does IPv6 have? (b) Is 192.168.1.300 a valid IPv4 address? (c) A classroom network must connect 100 devices. A subnet written as /p uses the first p bits for the network and leaves 32 − p bits for hosts. Which is the smallest block that fits, and how many addresses are spare?(a)IPv4 有多少个地址?IPv6 有多少个?(b)192.168.1.300 是有效的 IPv4 地址吗?(c)一个教室网络要连接 100 台设备。写作 /p 的子网用前 p 位表示网络,剩下 32 − p 位给主机。能容纳它们的最小地址块是哪个?还剩多少个地址?
(a) Totals. IPv4 has 32 bits, so 232 = 4,294,967,296 addresses (about 4.3 billion). IPv6 has 128 bits, so 2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456, about 3.4 × 1038. IPv6 has 296 (about 7.9 × 1028) times as many.(a) 总数。IPv4 有 32 位,所以有 232 = 4,294,967,296 个地址(约 43 亿)。IPv6 有 128 位,所以有 2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456 个,约 3.4 × 1038。IPv6 的地址数是 IPv4 的 296 倍(约 7.9 × 1028)。
(b) Validity. An IPv4 address is four numbers of 8 bits each (4 × 8 = 32 bits), so each number must be from 0 to 255. The last number, 300, is larger than 255, so 192.168.1.300 is not valid. For example 192.168.1.1 is 11000000.10101000.00000001.00000001 in binary.(b) 有效性。IPv4 地址由四个各占 8 位的数字组成(4 × 8 = 32 位),所以每个数字必须在 0 到 255 之间。最后一个数字 300 大于 255,所以 192.168.1.300 无效。例如 192.168.1.1 的二进制是 11000000.10101000.00000001.00000001。
(c) Subnet size. With h host bits there are 2h addresses, but the first (the network address) and the last (the broadcast address) are reserved, so usable hosts = 2h − 2. Try the options: /26 leaves 6 host bits, 26 − 2 = 62 hosts, too few. /25 leaves 7 host bits, 27 − 2 = 126 hosts, enough. So the smallest block is /25 (mask 255.255.255.128), with 126 − 100 = 26 spare addresses. A /24 (254 hosts) would also work but wastes 154.(c) 子网大小。有 h 个主机位时共有 2h 个地址,但第一个(网络地址)和最后一个(广播地址)被保留,所以可用主机数 = 2h − 2。逐个尝试:/26 留 6 个主机位,26 − 2 = 62 台,太少。/25 留 7 个主机位,27 − 2 = 126 台,够用。所以最小的块是 /25(掩码 255.255.255.128),剩余 126 − 100 = 26 个地址。/24(254 台)也可以,但会浪费 154 个。
import ipaddress
for prefix in (24, 25, 26):
net = ipaddress.ip_network(f"192.168.1.0/{prefix}")
hosts = net.num_addresses - 2
print(f"/{prefix}", net.netmask, net.num_addresses, "addresses,", hosts, "usable hosts")
print(2 ** 32)
print(2 ** 128)
print(int(ipaddress.ip_address("192.168.1.1")))
# output:
# /24 255.255.255.0 256 addresses, 254 usable hosts
# /25 255.255.255.128 128 addresses, 126 usable hosts
# /26 255.255.255.192 64 addresses, 62 usable hosts
# 4294967296
# 340282366920938463463374607431768211456
# 3232235777
Why this works: each extra bit doubles the count, so address problems are powers of 2. Subtract 2 only for usable hosts in a subnet. The 192.168.x.x block is private: it works inside a LAN and is shared out through NAT.为什么这样做:每多一位,数量翻一倍,所以地址问题都是 2 的幂。只有计算子网内可用主机数时才减 2。192.168.x.x 属于私有地址段:只在局域网内使用,通过 NAT 共享出口。
For explain what DNS does, say precisely that it translates a domain name into an IP address; do not write that it "finds the website" or encrypts anything. For a calculate question on addresses, write 2n first and then the number, and say whether you want all addresses or usable hosts (2h − 2). Common errors: calling 256 a valid IPv4 number, mixing up an IP address with a domain name, and thinking private addresses can be reached directly from the Internet.
遇到解释 DNS 的作用时,要准确地说它把域名翻译成 IP 地址;不要写成“找到网站”,也不要说它加密。遇到地址的计算(calculate)题,先写 2n,再写数值,并说明要的是全部地址还是可用主机数(2h − 2)。常见错误:把 256 当成有效的 IPv4 数字,混淆 IP 地址与域名,以及以为私有地址可以从互联网直接访问。
What does DNS do, and why can the Internet not simply use domain names to route packets?DNS 的作用是什么?为什么互联网不能直接用域名来路由数据包?
DNS translates a human-readable domain name such as example.com into an IP address. Routers forward packets by IP address, so a browser must look the name up first.
DNS 把 example.com 这样便于人读的域名翻译成 IP 地址。路由器按 IP 地址转发数据包,所以浏览器必须先查询域名。
Which of these are valid IPv4 addresses: 172.16.254.1, 10.0.0.256, 192.168.1, 8.8.8.8?下列哪些是有效的 IPv4 地址:172.16.254.1、10.0.0.256、192.168.1、8.8.8.8?
172.16.254.1 and 8.8.8.8 are valid. 10.0.0.256 is invalid because 256 is greater than 255. 192.168.1 is invalid because it has only three numbers instead of four.
172.16.254.1 和 8.8.8.8 有效。10.0.0.256 无效,因为 256 大于 255。192.168.1 无效,因为只有三个数字而不是四个。
How many usable hosts does a /27 subnet have? What is the smallest prefix that fits 50 devices?/27 子网有多少个可用主机?能容纳 50 台设备的最小前缀是什么?
/27 leaves 32 − 27 = 5 host bits: 25 − 2 = 30 usable hosts, too few for 50. /26 leaves 6 host bits: 26 − 2 = 62 usable hosts, enough. The smallest prefix that fits is /26.
/27 留 32 − 27 = 5 个主机位:25 − 2 = 30 台可用主机,容不下 50 台。/26 留 6 个主机位:26 − 2 = 62 台可用主机,够用。能容纳的最小前缀是 /26。
A resolver already has www.example.com in its cache. How does the next lookup differ from the first one?解析器的缓存里已经有 www.example.com。下一次查找与第一次有什么不同?
The resolver answers straight from its cache, so it skips the queries to the root, TLD and authoritative servers. The reply is faster, but it is only valid until the cached record expires.
解析器直接用缓存回答,跳过对根服务器、顶级域服务器和权威服务器的查询。回复更快,但只在缓存记录过期之前有效。
Protocols: TCP/IP, HTTP, and HTTPS协议:TCP/IP、HTTP 与 HTTPS
- Define a protocol and state the job of IP, TCP, UDP, HTTP and HTTPS.
- Describe the TCP three-way handshake (SYN, SYN-ACK, ACK).
- Compare TCP and UDP and justify the choice for a scenario.
- Match protocols to ports: HTTP 80, HTTPS 443, DNS 53.
- Count the round trips before the first byte of a page arrives with HTTP and with HTTPS.
- State what HTTPS adds to HTTP and what it does not protect.
- 定义协议(protocol),并说明 IP、TCP、UDP、HTTP 和 HTTPS 各自的作用。
- 描述 TCP 三次握手(SYN、SYN-ACK、ACK)。
- 比较 TCP 与 UDP,并为某个场景的选择说明理由。
- 把协议与端口对应起来:HTTP 80、HTTPS 443、DNS 53。
- 计算使用 HTTP 与 HTTPS 时,页面第一个字节到达之前需要几个往返。
- 说明 HTTPS 比 HTTP 多了什么,以及它不能保护什么。
- IP (Internet Protocol)IP(互联网协议): responsible for addressing and routing. Puts the sender's and destination's IP addresses on each packet. Connectionless; does not guarantee delivery or order.:负责寻址和路由。在每个数据包上放置发送方和目标的 IP 地址。无连接,不保证送达或顺序。
- TCP (Transmission Control Protocol)TCP(传输控制协议): adds reliability on top of IP. Establishes a connection (3-way handshake: SYN → SYN-ACK → ACK), numbers packets, requires acknowledgement (ACK) for each, retransmits lost packets, reorders out-of-sequence packets. Used for web pages, email, file transfer, anywhere accuracy matters. BC CIS 11 Content (verbatim): "four layers of the Transmission Control Protocol/Internet Protocol (TCP/IP).":在 IP 之上增加可靠性。建立连接(三次握手:SYN → SYN-ACK → ACK),对数据包编号,要求每个包的确认(ACK),重传丢失数据包,重新排序乱序数据包。用于网页、电子邮件、文件传输,任何需要准确性的场景。BC CIS 11 内容(原文):"TCP/IP 的四层。"
- UDP (User Datagram Protocol)UDP(用户数据报协议): fast but unreliable; no handshake, no ACK, no retransmission. Used for video streaming and online gaming where speed beats accuracy (a dropped frame is better than a frozen screen).:快速但不可靠;无握手、无 ACK、无重传。用于视频流和在线游戏,这些场景中速度优先于准确性(丢帧比画面卡顿更好)。
- HTTP / HTTPSHTTP / HTTPS: HTTP (HyperText Transfer Protocol) is the protocol browsers use to request and receive web pages. HTTPS = HTTP + TLS encryption; data is encrypted between browser and server. CSTA 3A-NI-07: "Compare various security measures, considering tradeoffs between the usability and security of a computing system.":HTTP(超文本传输协议)是浏览器用于请求和接收网页的协议。HTTPS = HTTP + TLS 加密;浏览器与服务器之间的数据被加密。CSTA 3A-NI-07:"比较各种安全措施,考虑计算系统可用性与安全性之间的权衡。"
Worked Example 7: Comparing TCP and UDP例题 7:比较 TCP 与 UDP
Which protocol to use depends on whether accuracy or speed matters more.选择哪种协议取决于准确性还是速度更重要。
| Feature特性 | TCPTCP | UDPUDP |
|---|---|---|
| Connection连接 | 3-way handshake before data数据传输前三次握手 | None (fire and forget)无(发送即忘) |
| Delivery guarantee送达保证 | Yes: ACK + retransmit是:ACK + 重传 | No否 |
| Ordering排序 | Yes: reorders packets是:重新排序数据包 | No否 |
| Speed速度 | Slower (overhead)较慢(开销大) | Faster较快 |
| Use cases使用场景 | HTTP/HTTPS, email, file transferHTTP/HTTPS、电子邮件、文件传输 | Video streaming, VoIP, online gaming视频流、VoIP、在线游戏 |
AP CSP Big Idea 4 (CSN) explains that the Internet is fault tolerant because redundant paths let packets reroute. TCP's retransmission handles the reliability layer; IP handles the routing layer. Classic HTTP (versions 1.1 and 2) is built on TCP, so those web page requests travel over a reliable TCP connection (HTTP/3 uses QUIC over UDP instead).AP CSP 大概念 4(CSN)说明:互联网因冗余路径让数据包可以改道而具有容错性。 TCP 的重传处理可靠性层;IP 处理路由层。经典的 HTTP(1.1 和 2 版)建立在 TCP 之上,因此这些网页请求通过可靠的 TCP 连接传输(HTTP/3 改用基于 UDP 的 QUIC)。
Worked Example 8: Choosing a transport protocol and counting round trips例题 8:选择传输协议并计算往返次数
The round-trip time (RTT) between a laptop and a server is 80 ms. (a) Choose TCP or UDP, with a reason, for: a PDF download, a live video call, a DNS lookup, and a bank login page. (b) How long before the first byte of a page arrives with plain HTTP, and with HTTPS using TLS 1.3 (one extra round trip) or TLS 1.2 (two extra)? Count only the handshakes and one request and response, and ignore DNS and server time.笔记本电脑和服务器之间的往返时间(RTT)是 80 ms。(a)为下列场景选择 TCP 或 UDP 并说明理由:下载 PDF、实时视频通话、DNS 查询、银行登录页面。(b)使用普通 HTTP,以及使用 TLS 1.3(多一个往返)或 TLS 1.2(多两个往返)的 HTTPS 时,页面的第一个字节要多久才到达?只计握手以及一次请求和响应,忽略 DNS 和服务器处理时间。
(a) Choices. PDF download: TCP, because every byte must arrive, complete and in order. Live video call: UDP, because a late frame is useless and waiting for a retransmission would freeze the call. DNS lookup: normally UDP (port 53), because the question and the answer are each small and the resolver can simply ask again if no reply comes; large replies can fall back to TCP. Bank login page: TCP with HTTPS on port 443, because the data must be complete and encrypted.(a) 选择。下载 PDF:TCP,因为每个字节都必须完整且按序到达。实时视频通话:UDP,因为迟到的画面没有用,等待重传会让通话卡住。DNS 查询:通常用 UDP(端口 53),因为问题和答案都很小,没有回复时解析器重新询问即可;回复较大时可改用 TCP。银行登录页面:TCP,并用 443 端口上的 HTTPS,因为数据必须完整且加密。
(b) Round trips. TCP handshake: SYN goes out and SYN-ACK comes back, which is 1 RTT; the final ACK travels together with the request. Then the HTTP request and response take 1 RTT. So plain HTTP needs 2 × 80 = 160 ms. TLS 1.3 adds one round trip: 3 × 80 = 240 ms. TLS 1.2 adds two: 4 × 80 = 320 ms. A UDP DNS query and answer is 1 RTT = 80 ms.(b) 往返次数。TCP 握手:发出 SYN,收到 SYN-ACK,共 1 个 RTT;最后的 ACK 与请求一起发送。随后 HTTP 请求和响应用 1 个 RTT。所以普通 HTTP 需要 2 × 80 = 160 ms。TLS 1.3 多 1 个往返:3 × 80 = 240 ms。TLS 1.2 多 2 个往返:4 × 80 = 320 ms。UDP 的 DNS 查询和应答是 1 个 RTT = 80 ms。
| Case情形 | Round trips往返次数 | Time at RTT = 80 msRTT = 80 ms 时的时间 |
|---|---|---|
| UDP DNS queryUDP 的 DNS 查询 | 1 | 80 ms |
| TCP + HTTP (port 80)TCP + HTTP(80 端口) | 2 | 160 ms |
| TCP + TLS 1.3 + HTTP (port 443)TCP + TLS 1.3 + HTTP(443 端口) | 3 | 240 ms |
| TCP + TLS 1.2 + HTTP (port 443)TCP + TLS 1.2 + HTTP(443 端口) | 4 | 320 ms |
Why this works: TCP and TLS spend round trips to buy reliability and encryption before any page data moves. UDP spends none, which is why real-time traffic uses it. The numbers are a simplified count; real browsers reuse connections to avoid some of these round trips.为什么这样做:TCP 和 TLS 先花费往返次数来换取可靠性和加密,之后页面数据才开始传输。UDP 不花这些往返,所以实时流量使用它。这里的数字是简化计数;真实浏览器会复用连接,省去其中一些往返。
For compare questions, use a small table with the same rows for both protocols (connection, delivery guarantee, ordering, speed, use). For justify the choice, tie the reason to the scenario: "a late video frame is useless, so retransmitting it wastes time" is better than "UDP is faster". Common errors: saying UDP is simply bad because it is unreliable, saying HTTPS makes the server itself safe (it protects data in transit), and saying TCP encrypts data (TLS does).
遇到比较(compare)题,用一个小表格,两种协议用相同的行(连接、送达保证、排序、速度、用途)。遇到说明选择理由(justify)时,把理由和场景联系起来:“迟到的视频帧没有用,重传只会浪费时间”比“UDP 更快”好。常见错误:因为 UDP 不可靠就说它不好,说 HTTPS 让服务器本身变安全(它保护的是传输中的数据),以及说 TCP 会加密数据(加密的是 TLS)。
What is a port, and why do HTTP and HTTPS use different ones?什么是端口?为什么 HTTP 和 HTTPS 使用不同的端口?
An IP address finds the machine; a port number says which program on that machine should receive the data. By convention HTTP uses port 80 and HTTPS uses port 443, so the server can tell plain and encrypted web traffic apart.
IP 地址找到那台机器;端口号说明该机器上哪个程序应接收数据。按惯例 HTTP 使用 80 端口,HTTPS 使用 443 端口,所以服务器能区分普通和加密的网页流量。
List the three steps of the TCP handshake in order and say what they achieve.按顺序列出 TCP 握手的三个步骤,并说明它们的作用。
SYN (client asks to connect), SYN-ACK (server agrees and acknowledges), ACK (client acknowledges). Both sides now know the other is reachable and have agreed starting sequence numbers, so delivery can be tracked and reordered.
SYN(客户端请求连接)、SYN-ACK(服务器同意并确认)、ACK(客户端确认)。双方现在都知道对方可达,并约定了起始序列号,因此可以跟踪送达和重新排序。
A multiplayer game sends each player's position 60 times a second. Should it use TCP or UDP? Explain.一个多人游戏每秒发送 60 次玩家位置。应该用 TCP 还是 UDP?请解释。
UDP. If one position update is lost, the next one arrives 1/60 s later and replaces it. With TCP, newer updates would wait behind the retransmission of the old one, making the game stutter.
UDP。如果丢了一次位置更新,1/60 秒后下一次更新就会到达并取代它。用 TCP 的话,较新的更新要排在旧更新的重传后面,游戏会卡顿。
Does HTTPS hide which server you are visiting from the network?HTTPS 会向网络隐藏你正在访问哪台服务器吗?
No. HTTPS encrypts the content of the conversation (pages, passwords, form data), but the network can still see the server's IP address and usually the domain name. Encryption in transit hides what is said, not who is talking.
不会。HTTPS 加密的是通信内容(页面、密码、表单数据),但网络仍然能看到服务器的 IP 地址,通常也能看到域名。传输加密隐藏的是说了什么,而不是谁在通信。
The Layered / OSI Model分层模型 / OSI 参考模型
- Name the seven OSI layers in order and give one protocol or device for each.
- Map the four TCP/IP layers onto the OSI layers.
- Explain encapsulation and decapsulation, and calculate the size of a message after each header is added.
- Explain why layering helps: each layer has one job and can be replaced without changing the others.
- Place a protocol or device (HTTP, TLS, TCP, IP, Ethernet, router, switch) at the correct layer.
- 按顺序说出 OSI 七层,并各举一个协议或设备。
- 把 TCP/IP 的四层对应到 OSI 的各层。
- 解释封装与解封装,并计算每加一个头部后消息的大小。
- 解释分层为什么有用:每层只做一件事,可以替换其中一层而不改变其他层。
- 把协议或设备(HTTP、TLS、TCP、IP、以太网、路由器、交换机)放到正确的层。
- BC CIS 11 Content (verbatim): "seven layers of the Open System Interconnection (OSI) reference model; 'interoperability' in the functioning of the Internet; four layers of the Transmission Control Protocol/Internet Protocol (TCP/IP)."BC CIS 11 内容(原文):"OSI 参考模型的七层;互联网运作中的'互操作性';TCP/IP 的四层。"
- Mnemonic for OSI layers 7→1: All People Seem To Need Data Processing (Application, Presentation, Session, Transport, Network, Data Link, Physical). Layer 7 is closest to the user; Layer 1 is the physical wire.OSI 七层(7→1)记忆口诀:应用、表示、会话、传输、网络、数据链路、物理。第 7 层最靠近用户;第 1 层是物理线路。
- The TCP/IP model (4 layers) collapses OSI's 7 into: Application (= OSI 5+6+7), Transport (= OSI 4), Internet (= OSI 3), Network Access / Link (= OSI 1+2).TCP/IP 模型(4 层)将 OSI 7 层合并为:应用层(= OSI 5+6+7)、传输层(= OSI 4)、网络层 / 互联网层(= OSI 3)、网络接入层 / 链路层(= OSI 1+2)。
Worked Example 9: The OSI seven layers with examples例题 9:OSI 七层及示例
What each layer does, and which protocols/hardware live there.每层的功能,以及对应的协议/硬件。
Layer | Name | Job | Examples ------+-------------------+--------------------------------+------------------- 7 | Application | User-facing services | HTTP, HTTPS, DNS, FTP 6 | Presentation | Data format / encryption | TLS/SSL, JPEG, MP3 5 | Session | Opening/closing sessions | NetBIOS, RPC 4 | Transport | End-to-end delivery, ports | TCP, UDP 3 | Network | Routing between networks | IP, ICMP, routers 2 | Data Link | Frame delivery on one link | Ethernet, Wi-Fi (802.11), MAC 1 | Physical | Bits on the wire / air | Cables, fibre, radio waves
A helpful analogy: sending a letter by courier. Layer 7 = the letter's content (your message). Layer 4 = the tracking number and the flat number on the parcel (which program receives it, and confirming it arrived). Layer 3 = the street address and the postal sorting office (routing by postcode). Layer 1 = the van's wheels on the road (physical transport). Each layer adds a header when sending and strips it when receiving; the two steps are called encapsulation and decapsulation.一个有用的比喻:快递寄信。第 7 层 = 信的内容(你的消息)。第 4 层 = 包裹上的运单号和门牌号(哪个程序接收,并确认送达)。第 3 层 = 街道地址和邮件分拣中心(按邮政编码路由)。第 1 层 = 货车在路上的车轮(物理运输)。每层发送时添加头部信息,接收时去除,称为封装和解封装。
Worked Example 10: Adding headers layer by layer (encapsulation)例题 10:逐层添加头部(封装)
A browser sends a 500-byte HTTP request. TCP adds a 20-byte header, IP adds a 20-byte header, and Ethernet adds a 14-byte header and a 4-byte trailer (minimum sizes, no options). Find the size after each layer, the total overhead, and the overhead as a percentage of what goes on the wire.浏览器发送一个 500 字节的 HTTP 请求。TCP 增加 20 字节头部,IP 增加 20 字节头部,以太网增加 14 字节头部和 4 字节尾部(最小长度,不含选项)。求每一层之后的大小、总开销,以及开销占线路上传输量的百分比。
Step 1: Application layer. The HTTP request is the data: 500 bytes.第 1 步:应用层。HTTP 请求就是数据:500 字节。
Step 2: Transport layer (TCP). 500 + 20 = 520 bytes (a segment).第 2 步:传输层(TCP)。500 + 20 = 520 字节(报文段)。
Step 3: Internet layer (IP). 520 + 20 = 540 bytes (a packet).第 3 步:网络互联层(IP)。520 + 20 = 540 字节(数据包)。
Step 4: Link layer (Ethernet). 540 + 14 + 4 = 558 bytes (a frame), which is 558 × 8 = 4,464 bits on the wire.第 4 步:链路层(以太网)。540 + 14 + 4 = 558 字节(帧),即线路上传输 558 × 8 = 4,464 比特。
Overhead. 558 − 500 = 58 bytes, and 58 ÷ 558 = 10.4% of the frame. The receiver reverses the process (decapsulation): Ethernet removes its header and trailer, IP removes its header, TCP removes its header, and the 500-byte request reaches the web server program. A switch reads only the Ethernet header (layer 2); a router reads the IP header (layer 3). The code checks the sizes:开销。558 − 500 = 58 字节,58 ÷ 558 = 帧的 10.4%。接收方反向处理(解封装):以太网去掉头部和尾部,IP 去掉头部,TCP 去掉头部,500 字节的请求到达 Web 服务器程序。交换机只读以太网头部(第 2 层);路由器读 IP 头部(第 3 层)。代码验证这些大小:
data = 500 # bytes of HTTP request (application layer)
segment = data + 20 # + 20-byte TCP header
packet = segment + 20 # + 20-byte IP header
frame = packet + 14 + 4 # + 14-byte Ethernet header + 4-byte trailer
print("application data:", data)
print("after TCP:", segment)
print("after IP:", packet)
print("after Ethernet:", frame)
print("overhead:", frame - data, "bytes")
print("overhead share:", round((frame - data) / frame * 100, 1), "%")
# output:
# application data: 500
# after TCP: 520
# after IP: 540
# after Ethernet: 558
# overhead: 58 bytes
# overhead share: 10.4 %
Why this works: each layer wraps the one above and only reads its own header, which is why Wi-Fi can replace Ethernet without changing TCP or HTTP. Figure 1 shows the same sizes beside the layer stack.为什么这样做:每一层都把上一层包起来,只读取自己的头部,所以 Wi-Fi 可以取代以太网而不用改动 TCP 或 HTTP。图 1 把同样的大小标在分层结构旁边。
For name the layers, write the number and the name together, in one direction (7 to 1 or 1 to 7), and add an example protocol; a small table is clearer than a paragraph. For place a protocol, decide by its job: routing by IP address is layer 3, end-to-end delivery and ports are layer 4. Common errors: putting HTTP at the transport layer, saying the TCP/IP model has seven layers, reversing the order of the layers, and forgetting that a switch works at layer 2 while a router works at layer 3. This guide places TLS at OSI layer 6; some books place it between layers 4 and 7, so name the layer you are using.
遇到说出各层(name)时,把编号和名称写在一起,按同一个方向(7 到 1 或 1 到 7)写,并加上示例协议;小表格比一段文字更清楚。遇到放置协议时,按它的作用判断:按 IP 地址路由是第 3 层,端到端传输和端口属于第 4 层。常见错误:把 HTTP 放在传输层,说 TCP/IP 模型有七层,把层的顺序写反,以及忘了交换机工作在第 2 层而路由器工作在第 3 层。本指南把 TLS 放在 OSI 第 6 层;有些书把它放在第 4 层和第 7 层之间,所以要说明你采用的是哪一层。
At which OSI layer does a router work, and which address does it read? What about a switch?路由器工作在 OSI 的哪一层?它读取哪种地址?交换机呢?
A router works at layer 3 (Network) and reads the destination IP address. A switch works at layer 2 (Data Link) and forwards frames by their MAC address.
路由器工作在第 3 层(网络层),读取目标 IP 地址。交换机工作在第 2 层(数据链路层),按 MAC 地址转发帧。
An application sends a 1,000-byte message. TCP adds 20 bytes, IP adds 20 bytes, and Ethernet adds 14 + 4 bytes. How big is the frame?一个应用发送 1,000 字节的消息。TCP 增加 20 字节,IP 增加 20 字节,以太网增加 14 + 4 字节。帧有多大?
1,000 + 20 = 1,020 after TCP; 1,020 + 20 = 1,040 after IP; 1,040 + 14 + 4 = 1,058 bytes after Ethernet. The overhead is 58 bytes.
TCP 之后 1,000 + 20 = 1,020;IP 之后 1,020 + 20 = 1,040;以太网之后 1,040 + 14 + 4 = 1,058 字节。开销是 58 字节。
Which TCP/IP layer replaces OSI layers 5, 6 and 7, and why is layering useful?TCP/IP 的哪一层取代了 OSI 的第 5、6、7 层?分层为什么有用?
The Application layer. Layering is useful because each layer does one job and talks only to the layers next to it, so one layer (for example Wi-Fi instead of Ethernet) can change without rewriting the others.
应用层。分层有用,因为每一层只做一件事,只与相邻的层通信,所以可以更换其中一层(例如用 Wi-Fi 代替以太网)而不用重写其他层。
Give the OSI layer number for DNS, TCP, IP, Wi-Fi and TLS (use this guide's table).写出 DNS、TCP、IP、Wi-Fi 和 TLS 所在的 OSI 层号(按本指南的表格)。
DNS: layer 7 (Application). TCP: layer 4 (Transport). IP: layer 3 (Network). Wi-Fi: layer 2 (Data Link). TLS: layer 6 (Presentation).
DNS:第 7 层(应用层)。TCP:第 4 层(传输层)。IP:第 3 层(网络层)。Wi-Fi:第 2 层(数据链路层)。TLS:第 6 层(表示层)。
Going deeper: interoperability and open standards BC CIS 11/12深入:互操作性与开放标准 BC CIS 11/12
BC CIS 11 Content names "International Organization for Standardization (ISO) in the creation of open standards for networking" and "'interoperability' in the functioning of the Internet." The OSI model is an ISO standard (ISO/IEC 7498-1). Interoperability means that a Mac, a Windows PC, and an Android phone can all send data to each other because they all implement the same open standards at each layer. Without open standards, every manufacturer would use proprietary protocols and devices from different vendors would be unable to communicate; similar to how locked-down app ecosystems restrict cross-platform data sharing. Open standards at the network layer are why the Internet is global rather than a patchwork of incompatible corporate networks.BC CIS 11 内容提到"ISO 在创建网络开放标准方面的作用"和"互联网运作中的'互操作性'"。OSI 模型是 ISO 标准(ISO/IEC 7498-1)。互操作性意味着 Mac、Windows PC 和 Android 手机都可以相互发送数据,因为它们在每一层都实现了相同的开放标准。没有开放标准,每个制造商都会使用专有协议,不同厂商的设备将无法通信,类似于封闭的应用生态系统如何限制跨平台数据共享。网络层的开放标准是互联网成为全球性而非一堆不兼容企业网络的原因。
Network Security Basics网络安全基础
- Explain what a firewall does and trace packets through an ordered rule list (first match wins, default block).
- Distinguish a virus, a worm, a Trojan, ransomware and spyware.
- Explain encryption in transit and say what it does not protect against.
- Recommend a defence for a threat and state its tradeoff.
- Explain why multi-factor authentication improves security but reduces convenience.
- 解释防火墙的作用,并让数据包依次通过有序规则列表(首个匹配生效,默认拦截)。
- 区分病毒、蠕虫、木马、勒索软件和间谍软件。
- 解释传输加密,并说明它不能防范什么。
- 针对某个威胁推荐防御措施,并说明其权衡。
- 解释多因素认证为什么提高安全性却降低便利性。
- Firewall防火墙: a hardware or software system that monitors and controls incoming and outgoing network traffic based on rules. It blocks unauthorised connections while allowing legitimate traffic. CSTA 3A-NI-06: "Recommend security measures to address various scenarios.":根据规则监控和控制进出网络流量的硬件或软件系统。它阻止未授权连接,同时允许合法流量。CSTA 3A-NI-06:"推荐安全措施以应对各种场景。"
- Encryption in transit传输加密: data is scrambled using a key so that anyone intercepting the packets sees only ciphertext. TLS (used by HTTPS) is the standard. CSTA 3A-NI-07: "Compare various security measures, considering tradeoffs between the usability and security of a computing system.":使用密钥对数据进行加密,使截获数据包的任何人只看到密文。TLS(HTTPS 使用)是标准做法。CSTA 3A-NI-07:"比较各种安全措施,考虑可用性与安全性之间的权衡。"
- Malware恶意软件: software designed to disrupt, damage, or gain unauthorised access. Types: virus (attaches to files), worm (self-replicates across the network without a host file), Trojan (disguised as legitimate software), ransomware (encrypts your files and demands payment), spyware (secretly monitors you). Ontario ICS3U C2.2 (verbatim): "describe procedures to safeguard data and programs from malware (e.g., viruses, Trojan horses, worms, spyware, adware, malevolent macros).":旨在破坏、损害或获取未授权访问的软件。类型:病毒(附着于文件)、蠕虫(无需宿主文件自行在网络中复制)、木马(伪装成合法软件)、勒索软件(加密你的文件并索要赎金)、间谍软件(秘密监视你)。安大略 ICS3U C2.2(原文):"描述保护数据和程序免受恶意软件(如病毒、木马、蠕虫、间谍软件、广告软件、恶意宏)侵害的程序。"
- Key security tradeoff关键安全权衡: stronger security often reduces usability (e.g., multi-factor authentication is more secure but slower). CSTA 3A-NI-08: "Explain tradeoffs when selecting and implementing cybersecurity recommendations.":更强的安全性通常降低可用性(如多因素认证更安全但更慢)。CSTA 3A-NI-08:"解释选择和实施网络安全建议时的权衡。"
Worked Example 11: A system protection plan例题 11:系统保护计划
Ontario ICS3U C2.2 asks students to "devise a thorough system protection plan." Here is a layered defence for a school network.安大略 ICS3U C2.2 要求学生"制定全面的系统保护计划"。以下是学校网络的分层防护方案。
| Threat威胁 | Defence measure防御措施 | Tradeoff权衡 |
|---|---|---|
| Unauthorised external access未授权外部访问 | Firewall: block all non-whitelisted ports防火墙:封锁所有非白名单端口 | May block legitimate services; needs configuration可能阻止合法服务;需要配置 |
| Password theft on shared Wi-Fi在共享 Wi-Fi 上的密码窃取 | HTTPS / TLS encryption in transitHTTPS / TLS 传输加密 | Slight performance overhead轻微性能开销 |
| Virus / worm infection病毒 / 蠕虫感染 | Anti-malware software + patch management反恶意软件 + 补丁管理 | Ongoing cost; may slow system during scans持续成本;扫描时可能降低系统速度 |
| Account compromise账户泄露 | Multi-factor authentication (MFA)多因素认证(MFA) | Extra step for users; less convenient用户需多一步;便利性降低 |
| Data loss from ransomware勒索软件导致的数据丢失 | Regular offline backups定期离线备份 | Storage cost; recovery takes time存储成本;恢复需要时间 |
CSTA 3A-NI-05: "Give examples to illustrate how sensitive data can be affected by malware and other attacks." The table above maps each attack vector to a concrete defence, satisfying CSTA 3A-NI-06 (recommend measures) and 3A-NI-08 (explain tradeoffs).CSTA 3A-NI-05:"举例说明敏感数据如何受到恶意软件和其他攻击的影响。"上表将每种攻击向量映射到具体防御措施,满足 CSTA 3A-NI-06(推荐措施)和 3A-NI-08(解释权衡)。
Worked Example 12: Tracing packets through firewall rules例题 12:让数据包依次通过防火墙规则
A school firewall checks its rules from top to bottom and the first matching rule decides. Rule 1: allow TCP port 443. Rule 2: allow TCP port 80. Rule 3: allow UDP port 53. Rule 4: block everything else. Decide what happens to five packets: TCP 443, TCP 22, UDP 53, UDP 443 and TCP 80. Then explain what would change if Rule 4 were moved to the top.学校防火墙从上到下检查规则,第一条匹配的规则生效。规则 1:允许 TCP 443 端口。规则 2:允许 TCP 80 端口。规则 3:允许 UDP 53 端口。规则 4:拦截其他所有流量。判断五个数据包的结果:TCP 443、TCP 22、UDP 53、UDP 443 和 TCP 80。然后说明如果把规则 4 移到最上面会发生什么。
| Packet数据包 | First matching rule首个匹配的规则 | Result结果 |
|---|---|---|
| TCP 443 | Rule 1规则 1 | Allow允许 |
| TCP 22 | Rule 4 (rules 1 to 3 do not match)规则 4(规则 1 到 3 不匹配) | Block拦截 |
| UDP 53 | Rule 3规则 3 | Allow允许 |
| UDP 443 | Rule 4 (rule 1 needs TCP, not UDP)规则 4(规则 1 要求 TCP,而不是 UDP) | Block拦截 |
| TCP 80 | Rule 2规则 2 | Allow允许 |
The same logic as code (the ANY rule matches any protocol and any port):同样的逻辑写成代码(ANY 规则匹配任何协议和任何端口):
# Rules are checked top to bottom; the first match decides. No match means block.
RULES = [
("allow", "TCP", 443),
("allow", "TCP", 80),
("allow", "UDP", 53),
("block", "ANY", None),
]
def decide(protocol, port):
for action, rule_proto, rule_port in RULES:
proto_ok = rule_proto in ("ANY", protocol)
port_ok = rule_port is None or rule_port == port
if proto_ok and port_ok:
return action
return "block"
packets = [("TCP", 443), ("TCP", 22), ("UDP", 53), ("UDP", 443), ("TCP", 80)]
for protocol, port in packets:
print(protocol, port, "->", decide(protocol, port))
# output:
# TCP 443 -> allow
# TCP 22 -> block
# UDP 53 -> allow
# UDP 443 -> block
# TCP 80 -> allow
Rule order matters. If "block everything" were Rule 1, every packet would match it first, so all 5 would be blocked and the school would have no web or DNS access. Tradeoff: a default-block firewall is safer because anything not listed is refused, but TCP 22 (remote login) stops working until someone adds a rule for it. A firewall also cannot stop a Trojan that a user downloads over an allowed port such as 443, so it is one layer of a plan, not the whole plan.规则顺序很重要。如果“拦截所有”是规则 1,每个数据包都会先匹配它,5 个包全部被拦截,学校就上不了网,也无法使用 DNS。权衡:默认拦截的防火墙更安全,因为没有列出的流量一律拒绝,但 TCP 22(远程登录)在有人为它添加规则之前无法使用。防火墙也无法阻止用户通过 443 这样的放行端口下载木马,所以它只是保护计划中的一层,而不是全部。
Why this works: a firewall is an ordered list of conditions, so tracing it is the same as stepping through an if / elif chain.为什么这样做:防火墙就是一个有序的条件列表,所以追踪它就像逐步执行 if / elif 链。
For recommend and justify questions, write three parts: the threat, the measure, and the tradeoff (for example "offline backups: they restore files after ransomware, but cost storage and take time to restore"). Name the malware type exactly: a worm spreads by itself, a Trojan is disguised, ransomware demands payment. Common errors: saying a firewall encrypts data, saying HTTPS protects you from malware on your own device, saying MFA makes an account unhackable, and forgetting that firewall rule order matters.
遇到推荐(recommend)和说明理由(justify)的题目,写出三个部分:威胁、措施和权衡(例如“离线备份:能在勒索软件之后恢复文件,但占用存储空间,恢复也需要时间”)。恶意软件类型要说准:蠕虫自己传播,木马伪装自己,勒索软件索要赎金。常见错误:说防火墙会加密数据,说 HTTPS 能保护你免受自己设备上的恶意软件侵害,说 MFA 让账户无法被攻破,以及忘了防火墙规则的顺序很重要。
Name the malware: (a) a free game that secretly installs a program, (b) a program that copies itself to other computers across the network with no host file, (c) a program that locks your files and demands payment.说出下列恶意软件的名称:(a)免费游戏,却悄悄安装了另一个程序;(b)无需宿主文件,自己通过网络复制到其他计算机;(c)锁住你的文件并索要赎金。
(a) Trojan. (b) Worm. (c) Ransomware.
(a)木马。(b)蠕虫。(c)勒索软件。
A page loads over HTTPS. Does that prove the site is trustworthy and safe to download from?一个页面通过 HTTPS 加载。这能证明该网站可信、下载是安全的吗?
No. HTTPS encrypts the data in transit so eavesdroppers cannot read it, but it does not check what the site does. A harmful site can also use HTTPS, so a Trojan can still arrive over an encrypted connection.
不能。HTTPS 加密传输中的数据,窃听者无法读取,但它不检查网站做了什么。有害网站也可以使用 HTTPS,所以木马仍可能通过加密连接到达。
Recommend one measure against ransomware on a school network and state its tradeoff.针对学校网络上的勒索软件推荐一项措施,并说明其权衡。
Regular offline backups: after an attack the files can be restored without paying. Tradeoff: storage cost, and restoring takes time, so recent work since the last backup can be lost. Keeping software patched is a second measure that costs staff time.
定期离线备份:遭到攻击后无需付赎金即可恢复文件。权衡:存储成本,而且恢复需要时间,上次备份之后的新工作可能丢失。保持软件及时打补丁是第二项措施,需要付出维护人员的时间。
Using the firewall from Worked Example 12, how many of the 5 packets are allowed? How many if "block everything" is moved to the top?使用例题 12 中的防火墙,5 个数据包中有几个被允许?如果把“拦截所有”移到最上面,有几个被允许?
3 are allowed (TCP 443, UDP 53, TCP 80). With "block everything" first, every packet matches it first, so 0 are allowed.
3 个被允许(TCP 443、UDP 53、TCP 80)。如果“拦截所有”排在第一位,每个包都先匹配它,所以 0 个被允许。
The Web vs. the Internet万维网与互联网的区别
- Distinguish the Internet from the Web, with examples of Internet services that are not the Web.
- Describe the client-server model: a client sends a request and the server sends a response.
- Split a URL into scheme, host, port, path, query and fragment.
- State the default ports (HTTP 80, HTTPS 443) and what a status code such as 200 or 404 tells you.
- Put the steps of loading a web page in order: DNS, TCP, TLS, HTTP.
- 区分互联网与万维网,并举出不属于万维网的互联网服务。
- 描述客户端-服务器模型:客户端发送请求,服务器发回响应。
- 把 URL 拆成协议、主机、端口、路径、查询和片段。
- 说出默认端口(HTTP 80、HTTPS 443),以及 200、404 这样的状态码表示什么。
- 按顺序排出加载网页的步骤:DNS、TCP、TLS、HTTP。
- The Internet互联网: a global network of networks that uses the TCP/IP protocol suite to route packets. It carries many services: the Web, email (SMTP), file transfer (FTP), video calls (VoIP), online gaming, IoT devices.:使用 TCP/IP 协议套件路由数据包的全球网络的网络。它承载多种服务:万维网、电子邮件(SMTP)、文件传输(FTP)、视频通话(VoIP)、在线游戏、物联网设备。
- The World Wide Web万维网: a system of interlinked hypertext documents (web pages) accessed via HTTP/HTTPS. Invented by Tim Berners-Lee in 1989 as one application running over the Internet. Uses URLs to identify resources, HTML to structure pages, and HTTP to transfer them.:通过 HTTP/HTTPS 访问的相互链接的超文本文档(网页)系统。由 Tim Berners-Lee 于 1989 年发明,作为运行在互联网上的一种应用。使用 URL 标识资源,HTML 构建页面,HTTP 传输它们。
- Client-server model客户端-服务器模型: a client (e.g. your browser) sends a request to a server (e.g. a web server). The server processes the request and sends back a response (e.g. an HTML page). AB CSE1210 and CSE1220 introduce "Internet computing through the use of … Web-specific markup languages"; that is the client-server Web model.:客户端(如你的浏览器)向服务器(如 Web 服务器)发送请求。服务器处理请求并返回响应(如 HTML 页面)。AB CSE1210 和 CSE1220 通过"Web 专用标记语言"介绍"互联网计算",即客户端-服务器 Web 模型。
- URL anatomyURL 解析: in
https://www.example.com:443/path?q=1#section,https= protocol,www.example.com= domain name (DNS resolves to IP),443= port (default for HTTPS),/path= resource path on the server,?q=1= query string,#section= fragment (in-page anchor).:在https://www.example.com:443/path?q=1#section中,https= 协议,www.example.com= 域名(DNS 解析为 IP),443= 端口(HTTPS 默认端口),/path= 服务器上的资源路径,?q=1= 查询字符串,#section= 片段(页内锚点)。
Worked Example 13: A browser loading a web page例题 13:浏览器加载网页
From typing a URL to seeing the page; every layer is involved.从输入 URL 到看到页面,每一层都参与其中。
You type: https://www.example.com/index.html
Step 1 DNS lookup: "www.example.com" -> 93.184.216.34
Step 2 TCP 3-way handshake: Browser --SYN--> Server
Browser <-SYN-ACK- Server
Browser --ACK--> Server
Step 3 TLS handshake: exchange certificates, agree on encryption key
Step 4 HTTP request (encrypted):
GET /index.html HTTP/1.1
Host: www.example.com
Step 5 HTTP response (encrypted):
HTTP/1.1 200 OK
Content-Type: text/html
[HTML body]
Step 6 Browser parses HTML, requests CSS/JS/images (repeat steps 4-5)
Step 7 Browser renders page on screen
Notice: DNS (Layer 7, Application) resolves the name. TCP (Layer 4, Transport) guarantees delivery. TLS (Layer 6, Presentation in OSI terms) encrypts. IP (Layer 3, Network) routes. Ethernet/Wi-Fi (Layer 2, Data Link) delivers the frame on the local link. Every OSI layer contributes to one page load.注意:DNS(第 7 层,应用层)解析名称。TCP(第 4 层,传输层)保证送达。TLS(OSI 第 6 层,表示层)加密。IP(第 3 层,网络层)路由。以太网/Wi-Fi(第 2 层,数据链路层)在本地链路上传送帧。每个 OSI 层都参与一次页面加载。
Worked Example 14: Splitting a URL with code例题 14:用代码拆分 URL
Label the parts of https://www.example.com:8443/path/page.html?q=networks&page=2#top. Which port would the browser use if :8443 were left out? Then confirm the parts with Python.标出 https://www.example.com:8443/path/page.html?q=networks&page=2#top 的各个部分。如果去掉 :8443,浏览器会使用哪个端口?然后用 Python 验证各部分。
| Part部分 | Value取值 | Meaning含义 |
|---|---|---|
| Scheme协议 | https | HTTP with TLS encryption带 TLS 加密的 HTTP |
| Host主机 | www.example.com | The domain name that DNS turns into an IP address由 DNS 转换成 IP 地址的域名 |
| Port端口 | 8443 | Which program on the server to contact (default for https is 443)要联系服务器上的哪个程序(https 的默认端口是 443) |
| Path路径 | /path/page.html | The resource on the server服务器上的资源 |
| Query查询 | q=networks&page=2 | Name=value pairs sent to the server发送给服务器的 名称=值 对 |
| Fragment片段 | top | A place inside the page; the browser uses it and does not send it to the server页面内的位置;由浏览器使用,不会发送给服务器 |
from urllib.parse import urlparse, parse_qs
url = "https://www.example.com:8443/path/page.html?q=networks&page=2#top"
parts = urlparse(url)
print("scheme:", parts.scheme)
print("host:", parts.hostname)
print("port:", parts.port)
print("path:", parts.path)
print("query:", parse_qs(parts.query))
print("fragment:", parts.fragment)
plain = urlparse("https://school.ca/grades?term=1")
print("port given:", plain.port)
# output:
# scheme: https
# host: www.example.com
# port: 8443
# path: /path/page.html
# query: {'q': ['networks'], 'page': ['2']}
# fragment: top
# port given: None
Default port. With :8443 left out, the URL does not name a port (Python prints None), and the browser uses the default for the scheme: 443 for https and 80 for http. parse_qs returns each value inside a list because a name can appear more than once.默认端口。去掉 :8443 后,URL 没有指明端口(Python 输出 None),浏览器使用该协议的默认端口:https 为 443,http 为 80。parse_qs 把每个值放在列表里,因为同一个名称可以出现多次。
Why this works: a URL is a structured address, where the scheme picks the protocol, the host is looked up by DNS, the port picks the program, and the path picks the resource.为什么这样做:URL 是结构化的地址,其中协议决定使用哪种协议,主机由 DNS 查询,端口决定联系哪个程序,路径决定要哪个资源。
For distinguish the Internet from the Web, give a one-line definition of each plus an example of an Internet service that is not the Web (email, file transfer, an online game): the Internet is the infrastructure, the Web is one service on it. For URL questions, name every part you label. Common errors: saying the Web and the Internet are the same thing, saying http:// pages are encrypted, saying the fragment is sent to the server, and treating a 404 response as a network failure.
遇到区分互联网与万维网时,各用一句话下定义,再给出一个不属于万维网的互联网服务(电子邮件、文件传输、在线游戏):互联网是基础设施,万维网是其上的一种服务。遇到 URL 题,要为你标出的每个部分命名。常见错误:说万维网和互联网是同一回事,说 http:// 页面是加密的,说片段会发送给服务器,以及把 404 响应当作网络故障。
Which of these are the Web, and which are Internet services that are not the Web: email, a school web page, an online game, file transfer (FTP)?下列哪些属于万维网,哪些是不属于万维网的互联网服务:电子邮件、学校网页、在线游戏、文件传输(FTP)?
The school web page is the Web (HTTP/HTTPS). Email, the online game and FTP are Internet services that are not the Web; they use their own protocols over the same Internet.
学校网页属于万维网(HTTP/HTTPS)。电子邮件、在线游戏和 FTP 是不属于万维网的互联网服务;它们在同一个互联网上使用各自的协议。
Label the parts of http://school.ca/grades?term=1&sort=name#top and give the default port.标出 http://school.ca/grades?term=1&sort=name#top 的各个部分,并给出默认端口。
Scheme: http. Host: school.ca. Path: /grades. Query: term=1&sort=name. Fragment: top. No port is written, so the browser uses the default for http, which is 80.
协议:http。主机:school.ca。路径:/grades。查询:term=1&sort=name。片段:top。没有写端口,所以浏览器使用 http 的默认端口 80。
A browser shows "404 Not Found". Did the network fail?浏览器显示“404 Not Found”。是网络出了故障吗?
No. The network worked: the request reached the server and the server answered. The answer says the requested path does not exist on the server. A status of 200 OK would mean the request succeeded.
不是。网络是正常的:请求到达了服务器,服务器也作了回应。回应说明请求的路径在服务器上不存在。状态码 200 OK 才表示请求成功。
Put these in order when you open https://school.ca: HTTP request, TLS handshake, DNS lookup, TCP handshake.打开 https://school.ca 时,把下列步骤排序:HTTP 请求、TLS 握手、DNS 查找、TCP 握手。
1. DNS lookup (find the IP address). 2. TCP handshake (open the connection). 3. TLS handshake (agree on encryption). 4. HTTP request (ask for the page, encrypted).
1. DNS 查找(找到 IP 地址)。2. TCP 握手(建立连接)。3. TLS 握手(约定加密)。4. HTTP 请求(请求页面,已加密)。
https://school.ca/grades?term=1, what does https specify?在 URL https://school.ca/grades?term=1 中,https 指定什么?:// is the scheme / protocol. https means HTTP with TLS encryption. The domain is school.ca; the path is /grades; the query string is term=1.:// 之前的部分是协议方案。https 表示带 TLS 加密的 HTTP。域名是 school.ca;路径是 /grades;查询字符串是 term=1。scheme://domain/path?query#fragment. The scheme (https) is the protocol. Domain = school.ca. Path = /grades. Query = term=1.URL 结构:协议://域名/路径?查询#片段。协议(https)是方案。域名 = school.ca。路径 = /grades。查询 = term=1。Exam Strategy and Common Pitfalls考试策略与常见陷阱
- Internet vs Web.互联网与万维网。 Keep these two terms apart. The Internet is the global TCP/IP network; the Web is the HTTP/HTTPS hypertext system running over it. Email, FTP, and online gaming are also Internet services; none of them are "the Web."请把这两个术语分清。互联网是全球 TCP/IP 网络;万维网是运行在其上的 HTTP/HTTPS 超文本系统。电子邮件、FTP 和在线游戏也是互联网服务,它们都不是"万维网"。
- LAN vs WAN.局域网与广域网。 LAN = one building/campus, privately owned. WAN = spans large distances, connects LANs. The Internet is a WAN (the largest WAN). State both the geographic scope and ownership when asked to distinguish them.局域网 = 一栋建筑/校园,私有。广域网 = 跨越大距离,连接多个局域网。互联网是一个广域网(最大的广域网)。被问到区别时,同时陈述地理范围和所有权。
- Protocol vs topology.协议与拓扑结构。 A protocol is a set of communication rules (TCP, HTTP). A topology is the physical or logical arrangement of devices (star, mesh). They are different dimensions of network design; mixing them up is a common error.协议是一套通信规则(TCP、HTTP)。拓扑结构是设备的物理或逻辑排布方式(星型、网状型)。它们是网络设计的不同维度,混淆它们是常见错误。
- Explain packets with three benefits.用三个优势解释数据包。 When asked why the Internet uses packet switching, state all three: (1) parallel routing, (2) selective retransmission of lost packets only, (3) fair bandwidth sharing. A one-line answer is incomplete.被问到互联网为何使用分组交换时,说出全部三个优势:(1)并行路由,(2)仅重传丢失的数据包,(3)带宽公平共享。只写一行的答案不完整。
- TCP vs UDP: always state the use case.TCP 与 UDP:始终陈述使用场景。 For any protocol comparison question, name the protocol, state whether it is reliable or fast, and give a concrete use case (TCP: web pages; UDP: video streaming). Three elements per protocol answer.对于任何协议比较题,命名协议,说明是可靠还是快速,并给出具体使用场景(TCP:网页;UDP:视频流)。每个协议答案包含三要素。
- OSI layer numbers matter (BC CIS).OSI 层编号很重要(BC CIS)。 In BC CIS, know all seven layer names and numbers. In AP CSP, understand the conceptual purpose of layering (each layer does one job and hides complexity from the layers above), which matters more than memorising all seven names.在 BC CIS 中,熟记全部七层的名称和编号。在 AP CSP 中,理解分层的概念目的(每层做一件事,向上层隐藏复杂性),比死记全部七层名称更重要。
- Name the malware type correctly.正确命名恶意软件类型。 Virus ≠ worm ≠ Trojan. On Ontario ICS3U C2.2 questions, be specific: a worm self-replicates across the network; a Trojan disguises itself; ransomware encrypts files for payment. Calling all malware a "virus" is too vague.病毒 ≠ 蠕虫 ≠ 木马。在安大略 ICS3U C2.2 题目中要具体:蠕虫在网络中自我复制;木马伪装自身;勒索软件加密文件索取赎金。把所有恶意软件笼统称为"病毒"不够准确。
- Security recommendation format (CSTA 3A-NI-06 to 3A-NI-08).安全建议格式(CSTA 3A-NI-06 至 3A-NI-08)。 A complete recommendation states the threat, the recommended measure, and the tradeoff (e.g., "Implement MFA: it reduces account compromise but adds a login step for every user"). The tradeoff is what CSTA 3A-NI-08 asks you to explain.完整的建议要陈述威胁、推荐措施和权衡(如"实施 MFA:降低账户泄露风险,但每个用户每次登录需额外步骤")。权衡正是 CSTA 3A-NI-08 要求你解释的内容。
- Use the correct technical term, not synonyms.使用正确的技术术语,而非同义词。 "Packet" not "chunk." "Protocol" not "rule." "Topology" not "layout." "Client-server" not "request-response pair" (unless the question uses that phrasing). Precise vocabulary makes an answer clear and checkable."数据包"而非"块"。"协议"而非"规则"。"拓扑结构"而非"布局"。"客户端-服务器"而非"请求-响应对"(除非题目使用该措辞)。精确的词汇让答案清晰、可核对。
- Draw the diagram if the question allows.如果题目允许,画出图示。 For a star topology question, a labelled sketch (central switch, labelled device nodes, arrows) is usually clearer than a paragraph. For a "name the layers" question, an OSI table (layer number | name | example protocol) is clearer than prose.拓扑结构题中,标注的草图(中央交换机、标注的设备节点、箭头)通常比段落更清楚。对于"命名各层"的题目,OSI 表格(层编号 | 名称 | 示例协议)比文字更清楚。
Flashcards闪卡
Practice Quiz综合测验
https://school.ca. In what order do the following steps occur: (A) TCP 3-way handshake, (B) DNS lookup, (C) TLS handshake, (D) HTTP GET request?你输入 https://school.ca。以下步骤的发生顺序是什么:(A)TCP 三次握手,(B)DNS 查找,(C)TLS 握手,(D)HTTP GET 请求?Readiness Checklist准备就绪清单
Tick each item when you can do it cold, without notes, on a first attempt.能在无笔记、首次尝试下完成,再勾选每一项。
- Distinguish LAN from WAN (geographic scope, ownership) and give two examples of each. Draw a star topology for a four-device LAN and label the central switch. 🇺🇸 CSTA 3A-NI-04 / 🇨🇦 BC CS10区分局域网与广域网(地理范围、所有权),各举两例。为四设备局域网画出星型拓扑并标注中央交换机。🇺🇸 CSTA 3A-NI-04 / 🇨🇦 BC CS10
- Explain packet switching: define a packet (header contents), state the three benefits (parallel routing, selective retransmission, fair bandwidth), and draw a simple ASCII diagram of packets taking different routes. 🇺🇸 AP CSP CSN-1.A解释分组交换:定义数据包(头部内容),陈述三大优势(并行路由、选择性重传、带宽公平共享),并画出数据包走不同路径的简单 ASCII 图。🇺🇸 AP CSP CSN-1.A
- Explain what DNS does, why it exists, and trace the steps of a DNS lookup from browser to root server to TLD server to authoritative server. 🇺🇸 CSTA 3A-NI-04解释 DNS 的作用和存在原因,并追踪从浏览器到根服务器、TLD 服务器、权威服务器的 DNS 查找步骤。🇺🇸 CSTA 3A-NI-04
- Compare TCP and UDP on four dimensions (connection, delivery guarantee, ordering, speed) and give a concrete use case for each that justifies the choice. 🇨🇦 BC CIS 11在四个维度(连接、送达保证、排序、速度)上比较 TCP 与 UDP,并各举一个证明选择合理的具体使用场景。🇨🇦 BC CIS 11
- Explain what HTTPS adds over HTTP and why you should always use HTTPS for login pages. Define encryption in transit in one sentence. 🇺🇸 CSTA 3A-NI-07解释 HTTPS 在 HTTP 基础上增加了什么,以及为什么登录页面始终应使用 HTTPS。用一句话定义传输加密。🇺🇸 CSTA 3A-NI-07
- Name all seven OSI layers in order (7→1), state the job of each, and give one protocol example per layer. Map the four TCP/IP layers to their OSI equivalents. 🇨🇦 BC CIS 11 (verbatim content)按顺序(7→1)命名 OSI 全部七层,说明每层职能,并各举一个协议示例。将 TCP/IP 四层映射到对应的 OSI 层。🇨🇦 BC CIS 11(原文内容)
- Distinguish virus, worm, Trojan, ransomware, and spyware in one sentence each. Devise a four-item system protection plan for a school network with a named measure and tradeoff for each threat. 🇨🇦 ON ICS3U C2.2 / 🇺🇸 CSTA 3A-NI-05 / 3A-NI-06各用一句话区分病毒、蠕虫、木马、勒索软件和间谍软件。为学校网络制定包含四项措施的系统保护计划,每项威胁附上具体措施和权衡。🇨🇦 ON ICS3U C2.2 / 🇺🇸 CSTA 3A-NI-05 / 3A-NI-06
- Explain the Internet vs. the Web distinction. Name three Internet services that are not the Web. Define client-server model and label the parts of the URL
https://school.ca/grades?term=1. 🇨🇦 AB CSE1210 / 🇺🇸 AP CSP解释互联网与万维网的区别。举出三项不属于万维网的互联网服务。定义客户端-服务器模型,并标注 URLhttps://school.ca/grades?term=1的各部分。🇨🇦 AB CSE1210 / 🇺🇸 AP CSP - Explain fault tolerance in the context of the Internet: why can data reach its destination even when some routers fail? Link this to mesh topology. 🇺🇸 AP CSP 4.2 (CSN-1.C)在互联网语境下解释容错性:为什么即使某些路由器故障,数据仍能到达目的地?将此与网状拓扑相联系。🇺🇸 AP CSP 4.2 (CSN-1.C)
- State the CSTA standards 3A-NI-04, 3A-NI-05, and 3A-NI-07 (near-verbatim) and explain what each one requires a student to do. 🇺🇸 CSTA Level 3A近逐字陈述 CSTA 标准 3A-NI-04、3A-NI-05 和 3A-NI-07,并解释每项要求学生做什么。🇺🇸 CSTA Level 3A
- Honors: BC CIS 12 Describe "interoperability" in the context of open networking standards. Explain why the Internet requires open standards (OSI/TCP-IP) rather than proprietary protocols, and name the ISO document that formalises the OSI model. 🇨🇦 BC CIS 11 (verbatim)荣誉:BC CIS 12 在开放网络标准的语境下描述"互操作性"。解释为什么互联网需要开放标准(OSI/TCP-IP)而非专有协议,并命名使 OSI 模型正式化的 ISO 文件。🇨🇦 BC CIS 11(原文)
What This Feeds Into本单元的去向
Networks and the Internet underpins three major downstream areas. First, the cybersecurity and ethics unit (Unit 12) extends the security concepts in §6: you will go from understanding what a firewall does to evaluating legal, ethical, and societal implications of computing security decisions. Second, AP CSP Big Idea 4 (Computer Systems & Networks) matches this unit's content closely, so if you are taking AP CSP, this guide is core reading. Third, the web-scripting pathway (AB CSE1210/1220; any school teaching HTML/CSS/JavaScript) builds directly on the client-server and HTTP foundations in §7.网络与互联网为三大下游领域奠定基础。第一,网络安全与伦理单元(第 12 单元)扩展了 §6 中的安全概念:你将从理解防火墙的作用,进阶到评估计算安全决策的法律、伦理和社会影响。第二,AP CSP 大概念 4(计算机系统与网络)与本单元内容高度对应,若你学习 AP CSP,本指南是核心读物。第三,Web 脚本路径(AB CSE1210/1220;任何教授 HTML/CSS/JavaScript 的学校)直接建立在 §7 中客户端-服务器和 HTTP 基础之上。
Within High School Computer Science.在 HS Computer Science 内部。
Unit 12 (Cybersecurity, Ethics and Society) is the natural continuation of §6 (Network Security Basics); CSTA 3A-NI-05 through 3A-NI-08 and the malware taxonomy all feed directly into that unit. Unit 10 (Data, Databases and the Web) pairs with §7 of this guide: understanding how HTTP carries data between browser and server is a prerequisite for understanding web forms, APIs, and database queries. The Boolean Logic unit (Unit 9) connects at Layer 2 (Data Link); understanding that all data is ultimately bits on a wire ties number systems to physical networking.第 12 单元(网络安全、伦理与社会)是 §6(网络安全基础)的自然延伸,CSTA 3A-NI-05 至 3A-NI-08 以及恶意软件分类法都直接延伸至该单元。第 10 单元(数据、数据库与 Web)与本指南的 §7 配套:理解 HTTP 如何在浏览器与服务器之间传输数据,是理解网络表单、API 和数据库查询的前提。布尔逻辑单元(第 9 单元)在第 2 层(数据链路层)相连,理解所有数据最终都是线路上的比特,将数字系统与物理网络联系起来。
AP and downstream connections.AP 及下游连接。
AP CSA has no networks unit (it focuses on Java OOP and does not cover network protocols). The primary AP feeder is AP CSP Big Idea 4 (CSN). If you are on the AP CSP track, focus on §2 (packets), §4 (TCP/IP, HTTP), and §6 (security tradeoffs); these map to the CSN Learning Objectives CSN-1.A through CSN-1.E in the AP CSP course. BC CIS students heading into network administration or IT programs will find §5 (OSI model) the most directly applicable, as it maps verbatim to the CIS 11 Content standards.AP CSA 没有网络单元(它专注于 Java 面向对象,不涉及网络协议)。主要的 AP 衔接是 AP CSP 大概念 4(CSN)。若你在 AP CSP 轨道上,重点学习 §2(数据包)、§4(TCP/IP、HTTP)和 §6(安全权衡),这些对应 AP CSP 课程中的 CSN 学习目标 CSN-1.A 至 CSN-1.E。计划进入网络管理或 IT 专业的 BC CIS 学生会发现 §5(OSI 模型)最直接适用,因为它与 CIS 11 内容标准原文对应。
This is the ladder we coach students up: from these high school foundations into AP and IB, and on to first-year university. If you would rather have a guide for the next step than take it on trust, Dingrui Scholars tutors teach exactly this path in one-on-one sessions and small-group classes. A free assessment is the place to start.这正是我们陪伴学生攀登的阶梯:从这些高中基础,迈入 AP 与 IB,再走向大学一年级。如果你希望在下一步有人引路,而不是凭感觉前行,Dingrui Scholars 的导师正是沿着这条路径,以一对一辅导与小班课授课。欢迎从免费评估开始。
Common Questions常见问题
What is the difference between the Internet and the Web?互联网和万维网有什么区别?
The Internet is a global network of networks that uses TCP/IP to route packets and carries many services, while the Web is just one of those services, a system of interlinked hypertext pages accessed over HTTP/HTTPS using URLs. The Web runs on top of the Internet.互联网是使用 TCP/IP 路由数据包的全球网络之网,承载着许多服务;万维网只是其中一种服务,是通过 HTTP/HTTPS 用网址访问的相互链接的超文本页面系统。万维网运行在互联网之上。
How does data travel across the Internet in packets?数据是如何以数据包形式在互联网上传输的?
Data is broken into small packets, typically 1,500 bytes or less, each carrying a header with the source and destination IP addresses and packet numbers. Each packet can take a different route, and they are reassembled in order at the destination.数据被拆成小的数据包,通常不超过 1500 字节,每个包的头部带有源 IP 地址、目标 IP 地址和包编号。每个包可以走不同的路由,到达目的地后再按顺序重新组装。
What is the difference between TCP and UDP?TCP 和 UDP 有什么区别?
TCP adds reliability on top of IP by using a handshake, numbering packets, requiring acknowledgements, and retransmitting lost packets, so it suits web pages and email. UDP is fast but unreliable with no handshake or retransmission, which suits video streaming and gaming where speed beats accuracy.TCP 在 IP 之上增加可靠性,使用握手、给数据包编号、要求确认并重传丢失的包,因此适合网页和电子邮件。UDP 快但不可靠,没有握手也不重传,适合速度优先于准确性的视频流和游戏。
Syllabus alignment & how to use this guide大纲对照与使用说明
How to use this guide如何使用本指南
Networks and the Internet is covered at very different depth across the four curricula. AP CSP Big Idea 4 (Computer Systems & Networks) is the closest match: you need to explain packets, protocols, fault tolerance, and the Internet's structure. BC's Computer Information Systems 11/12 stream goes deepest on infrastructure: OSI seven-layer model, TCP/IP four-layer model, WAN/LAN, topologies, and network management. Ontario's university stream (ICS3U/ICS4U) is the lightest: only malware protection (C2.2) is named; protocol and topology content appears in the Grade 10 open course and the college stream. Alberta CSE covers the Internet only through Web scripting modules; protocol/topology content sits in the separate NET cluster.网络与互联网在四套大纲中的涉及深度差异很大。AP CSP 大概念 4(计算机系统与网络)最为对应:需要解释数据包、协议、容错和互联网结构。BC 的 CIS 11/12 方向对基础设施要求最深:OSI 七层模型、TCP/IP 四层模型、WAN/LAN、拓扑结构和网络管理。安大略大学方向(ICS3U/ICS4U)最轻:仅点名恶意软件防护(C2.2);协议和拓扑内容出现在 10 年级公开课和大专方向中。阿尔伯塔 CSE 仅通过 Web 脚本模块涉及互联网;协议/拓扑内容属于独立的 NET 模块群。
| If you are in…如果你在… | Focus on these sections重点学习 | Lighter / context only较轻 / 仅作背景 | Source依据 |
|---|---|---|---|
| 🇺🇸 US CSTA / AP CSP美国 CSTA / AP CSP | §1–§7 in full. AP CSP Big Idea 4 (CSN-1.A through CSN-1.E) covers Internet structure, packets, protocols, and fault tolerance. CSTA 3A-NI-04 to 3A-NI-08 add scalability, security, and tradeoffs.§1 至 §7 完整学习。AP CSP 大概念 4(CSN-1.A 至 CSN-1.E)涵盖互联网结构、数据包、协议和容错。CSTA 3A-NI-04 至 3A-NI-08 增加可扩展性、安全性和权衡。 | OSI layer detail in §5 going-deeper is context for AP CSP; what matters for AP CSP is the idea of layers, not the order of their names.§5 深入中的 OSI 层详情对 AP CSP 为背景知识;对 AP CSP 而言,重要的是分层的思想,而不是各层名称的顺序。 | CSTA K-12 and AP CSP: CSTA 3A-NI-04 through 3A-NI-08; AP CSP Big Idea 4 (CSN) topics 4.1, 4.2, 4.3CSTA 3A-NI-04 至 3A-NI-08;AP CSP 大概念 4(CSN)主题 4.1、4.2、4.3 |
| 🇨🇦 ON Grade 11: ICS3U安大略 11 年级:ICS3U | §6 (security basics, malware) is the main content here and matches ICS3U C2.2 directly. §1 (LAN/WAN) and §7 (Web vs Internet) as background literacy.§6(安全基础、恶意软件)是主要内容,直接对应 ICS3U C2.2。§1(LAN/WAN)和 §7(Web 与互联网)作为背景知识。 | Protocol depth in §4 and the OSI model in §5 are not part of the ICS3U/ICS4U university stream; treat them as enrichment.§4 的协议深度和 §5 的 OSI 模型不属于 ICS3U/ICS4U 大学方向,作为拓展内容。 | ON/BC Computer Studies 11-12: ICS3U Strand C C2.2; ICS3C C1.4; ICS2O A4ICS3U C 单元 C2.2;ICS3C C1.4;ICS2O A4 |
| 🇨🇦 BC: CIS 11 / CIS 12BC: CIS 11 / CIS 12 | §1–§7 in full. CIS 11 Content names OSI seven layers, TCP/IP four layers, WAN/LAN, topologies, and "key aspects of network protocols and standards" verbatim. CIS 12 adds deployment, maintenance, and security management.§1 至 §7 完整学习。CIS 11 内容原文命名 OSI 七层、TCP/IP 四层、WAN/LAN、拓扑结构和"网络协议和标准的关键方面"。CIS 12 增加部署、维护和安全管理。 | CIS 12 network-device design and remote-access tools are beyond this guide's scope; see the CIS 12 course page.CIS 12 网络设备设计和远程访问工具超出本指南范围,参见 CIS 12 课程页面。 | ON/BC Computer Studies 11-12: BC CS10 networking Content; CIS 11 network planning / OSI / TCP/IP Content; CIS 12 deployment ContentBC CS10 网络内容;CIS 11 网络规划 / OSI / TCP/IP 内容;CIS 12 部署内容 |
| 🇨🇦 AB: CSE scripting / NET cluster阿尔伯塔:CSE 脚本 / NET 模块群 | §7 (the Web, client-server, URLs) maps to CSE1210/CSE1220 (Client-side Scripting 1 & 2) which "introduce Internet computing." §1 (LAN/WAN) and §6 (security) as background literacy for any computing course.§7(Web、客户端-服务器、URL)对应 CSE1210/CSE1220(客户端脚本 1 和 2),它们"介绍互联网计算"。§1(LAN/WAN)和 §6(安全)作为任何计算课程的背景知识。 | Protocol and OSI layer detail (§4, §5) are in the NET cluster, not CSE; treat as enrichment for CSE students.协议和 OSI 层详情(§4、§5)属于 NET 模块群,不属于 CSE,对 CSE 学生作为拓展内容。 | Alberta CTS Computing Science: CSE1210, CSE1220 descriptions; NET cluster noteCSE1210、CSE1220 描述;NET 模块群说明 |
Memorise five things: what a packet is and why data travels in packets; what IP addresses and DNS do; the difference between TCP and UDP (reliable vs fast); what HTTP vs HTTPS means; and what a firewall does. Read every cram-cheat box. Skip the OSI seven-layer name list in the going-deeper box unless you are in BC CIS.背熟五件事:什么是数据包以及为什么数据以数据包传输;IP地址和DNS的作用;TCP 与 UDP 的区别(可靠 vs 快速);HTTP 与 HTTPS 的含义;防火墙的作用。读每个速记框,除非你在 BC CIS,否则跳过深入框中的 OSI 七层名称列表。
For AP CSP: understand how packets are routed, why the Internet is fault-tolerant (multiple paths), and the tradeoff between reliability (TCP) and speed (UDP). For BC CIS: know all seven OSI layers by name and function, the four TCP/IP layers, and the difference between logical and physical topologies. For all curricula: be able to explain why HTTPS is more secure than HTTP, and what a firewall does.AP CSP 要求:理解数据包如何路由、为什么互联网具有容错性(多路径),以及可靠性(TCP)与速度(UDP)的权衡。BC CIS 要求:按名称和功能熟知 OSI 七层、TCP/IP 四层,以及逻辑拓扑与物理拓扑的区别。所有大纲要求:能解释为什么 HTTPS 比 HTTP 更安全,以及防火墙的作用。